import FastClick from 'fastclick';
import { useSelector } from 'umi';
import { persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import autoMergeLevel2 from 'redux-persist/es/stateReconciler/autoMergeLevel2';
import '@/utils/device';
import 'animate.css';
import '@/style/global.less';

FastClick.attach(document.body);



export const dva = {
  config: {
    onReducer(reducer: any) {
      /* 数据持久化配置 */
      const persistConfig = {
        key: 'root',
        storage,
        stateReconciler: autoMergeLevel2,
        whitelist: ['store', 'order', 'payment', 'currentstore', 'cartList'],
      };
      return persistReducer(persistConfig, reducer);
    },
    onError(err:any) {
      err.preventDefault();
      console.error(err.message);
    },
  },
};

export function onRouteChange({ matchedRoutes, ...args }: any) {
  if (matchedRoutes.length) {
    // document.title = braName;
  }
}
